
package pie.basic.outline;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartFrame;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PiePlot;
import org.jfree.data.general.DefaultPieDataset;

/**
 * controlling the outline of the pie sections.
 * 
 * @author Eric.Kao(gau168.gau@msa.hinet.net)
 * @version 1.0
 * @company E885 Group
 * @copyright Copyright (c) 2001-2008
 */

public class ControllingOutlineVisiblity
{
	private String section1 = "Category 1";

	private String section2 = "Category 2";

	private String section3 = "Category 3";

	public ControllingOutlineVisiblity()
	{
		JFreeChart chart = createPieChart();

		// controlling the outline of sections.
		// you have to get PiePlot first.
		PiePlot piePlot = ( PiePlot )chart.getPlot();

		// switch off the outline of the section.
		piePlot.setOutlineVisible( false );

		display( chart );
	}

	/**
	 * @param args
	 */
	public static void main( String[] args )
	{
		new ControllingOutlineVisiblity();
	}

	private JFreeChart createPieChart()
	{
		DefaultPieDataset pieDataset = new DefaultPieDataset();
		pieDataset.setValue( section1, 43.2 );
		pieDataset.setValue( section2, 27.9 );
		pieDataset.setValue( section3, 79.5 );

		return ChartFactory.createPieChart( "sample chart", pieDataset, true, true, false );
	}

	private void display( JFreeChart chart )
	{
		ChartFrame frame = new ChartFrame( "Test", chart );
		frame.pack();
		frame.setVisible( true );
	}
}
